#ifndef PLOTFORM_H
#define PLOTFORM_H

#include <QMainWindow>
#include <QChart>
#include <QSplineSeries>
#include <QCheckBox>
#include <QColor>

#define SERIES_COUNT 9
#define FILE_MAX_SIZE_KB 64

namespace Ui {
class PlotForm;
}

class PlotForm : public QMainWindow
{
    Q_OBJECT

public:
    explicit PlotForm(QWidget *parent = nullptr);
    ~PlotForm();

signals:
    void SigProtocol(const QDateTime& datetime, const QList<float>& data);

    void SigPlotChart2(const double& dataX, const QList<double>& dataY);

private:
    void initForm();
    void initChart();
    //初始化 图表2
    void initChart2();
    void initCheckBox();
    void initColor();



    /**
     * @brief 检查文件大小是否超过FILE_MAX_SIZE_KB
     */
    void checkFileSize(const QString& path);

    Ui::PlotForm *ui;
    QChart* m_chart;
    QChart* m_chart2;

    QList<QLineSeries*> m_seriesList;
    QList<QLineSeries*> m_seriesList2;
    QList<QColor> m_colorList;
    QMap<int, QCheckBox*> m_checkBoxMap;

    float m_max = 0.0f;
    float m_min = 1000000.0f;

    double m_chart2X_min = INT_MAX;
    double m_chart2X_max = INT_MIN;

    double m_chart2Y_min = INT_MAX;
    double m_chart2Y_max = INT_MIN;
};

#endif // PLOTFORM_H
